package net.easyunion.dataservice.main;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.easyunion.dataservice.common.tool.ApplicationConfig;
import net.easyunion.dataservice.dao.impl.JdbcDataManager;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ServerStart {

	@Resource
	private JdbcDataManager dataManager;
	
//	@RequestMapping(value = "init")
//	public ModelAndView manager(HttpServletRequest request,
//			HttpServletResponse response) {
//		
//		System.out.println("123456");
//		ModelAndView mv = new ModelAndView("/index/index", "command", "LOGIN SUCCESS");
//		dataManager.managerDBSource();
//		JdbcTemplate jt = ApplicationConfig.JDBC_LRU.get("1");
//		int num = jt.queryForInt("select count(*) from datasource_prop;");
//		System.out.println(num);
//		return mv;
//	}
	
	@RequestMapping(value = "init")
	public void init(HttpServletRequest request,
			HttpServletResponse response) {
		dataManager.loadDBSource();
		
		
		JdbcTemplate jt = ApplicationConfig.JDBC_LRU.get("1");
		int num = jt.queryForInt("select count(*) from datasource_prop;");
		System.out.println(num);
	}
}
